<!-- src/App.vue -->
<template>
  <el-config-provider :locale="locale">
    <router-view />
  </el-config-provider>
</template>
<script lang="ts" setup>
import { computed, onMounted, ref, watch } from "vue";
import { ElConfigProvider } from "element-plus";

import { useAppStore } from "@/store/modules/app";

// 导入 Element Plus 语言包
import zhCn from "element-plus/es/locale/lang/zh-cn";
import en from "element-plus/es/locale/lang/en";

const language = computed(() => useAppStore().language);
const locale = ref();
watch(
  language,
  (value) => {
    if (value == "en") {
      locale.value = en;
    } else {
      // 默认中文
      locale.value = zhCn;
    }
  },
  {
    // 初始化立即执行
    immediate: true,
  }
);
</script>

<style scoped lang="less"></style>
